const {ccclass, property} = cc._decorator;

@ccclass
export default class enable_phy extends cc.Component {

    @property(cc.Vec2)
    gravity: cc.Vec2 = cc.v2(0, -320);

    @property({tooltip: '是否打开调试区域'})
    is_debug: boolean = false;

    // LIFE-CYCLE CALLBACKS:
    // 开启物理引擎一定要写到onLoad里面， start里面写无效
    onLoad () {
        // 1. 开启物理引擎
        cc.director.getPhysicsManager().enabled = true
        // 2. 配置物理引擎的重力
        cc.director.getPhysicsManager().gravity = this.gravity

        // 3. 配置调试区域
        if (this.is_debug) {
            const Bits: any = cc.PhysicsManager.DrawBits;
            cc.director.getPhysicsManager().debugDrawFlags = Bits.e_aabbBit | Bits.e_pairBit | Bits.e_centerOfMassBit | Bits.e_jointBit | Bits.e_shapeBit;
        } else {
            cc.director.getPhysicsManager().debugDrawFlags = 0
        }
    }

    start () {

    }

    // update (dt) {}
}
